import request from "./request"
// 登录
export function Login(data) {
    return request({
        url: "/login",
        method: "POST",
        data
    })
}
// 左侧菜单
export function DaoHang() {
    return request({
        url: "/menus",
        method: "GET",
    })
}
// 请求用户列表
export function YongHu(params) {
    return request({
        url: "/users",
        method: "GET",
        params
    })
}
// 添加用户
export function TianJia(data) {
    return request({
        url: "/users",
        method: "POST",
        data
    })
}
// 删除用户
export function ShanChu(data) {
    return request({
        url: "/users/" + data,
        method: "DELETE",
    })
}
// 编辑用户
export function BianJi(data) {
    return request({
        url: "/users/" + data.id,
        method: "PUT",
        data
    })
}
// 状态改变
export function ZhuangTai(uid, type) {
    return request({
        url: `users/${uid}/state/${type}`,
        method: "PUT",
    })
}
// 角色列表
export function JueSe() {
    return request({
        url: '/roles',
        method: 'GET'
    })
}
// 分配角色列表
export function JueSeUser(id, rid) {
    return request({
        url: `/users/${id}/role`,
        method: 'PUT',
        data: { rid }
    })
}
// 添加角色
export function RolesAdd(data) {
    return request({
        url: "roles",
        method: 'POST',
        data
    })
}
// 删除角色
export function RolesDel(id) {
    return request({
        url: `roles/${id}`,
        method: 'delete',
    })
}
// 编辑角色
export function RolesEdit(data) {
    return request({
        url: `roles/${data.id}`,
        method: 'put',
        data
    })
}
// 权限列表
export function RightList(type = "list") {
    return request({
        url: `rights/${type}`,
        method: 'get',
    })
}
// 删除后剩余的角色权限
export function RightRoled(roleld, rightid) {
    return request({
        url: `roles/${roleld}/rights/${rightid}`,
        method: 'delete',
    })
}
// 角色权限列表
export function RolesList(roleld, rids) {
    return request({
        url: `roles/${roleld}/rights`,
        method: 'post',
        data: { rids }
    })
}
// 商品列表
export function GoodsList(params) {
    return request({
        url: "goods",
        method: 'GET',
        params
    })
}
// 商品删除
export function GoodsListDel(id) {
    return request({
        url: `goods/${id}`,
        method: 'delete',
    })
}
// 商品分类数据列表
export function GoodsFenLei(params) {
    return request({
        url: "categories",
        method: 'get',
        params
    })
}
// 订单列表渲染
export function Orders(params) {
    return request({
        url: "orders",
        method: "get",
        params
    })
}
// 订单列表删除
export function OrdersDel(id) {
    return request({
        url: `categories/${id}`,
        method: 'DELETE',
    })
}
// 商品参数列表接口
export function AddGoodsList(id, sel = 'many') {
    return request({
        url: `categories/${id}/attributes`,
        method: "get",
        params: { sel }
    })
}
// 添加商品
export function AddGoods(data) {
    return request({
        url: "/goods",
        method: "post",
        data
    })
}
// 添加分类
export function AddFenLei(data) {
    return request({
        url: "categories",
        method: "post",
        data
    })
}
// 编辑分类
export function FenLeiEdit(data) {
    return request({
        url: `categories/${data.id}`,
        method: "put",
        data
    })
}
// 动态静态参数列表
export function canshuliebiao(id, sel) {
    return request({
        url: `categories/${id}/attributes`,
        method: "get",
        params: { sel }
    })
}
// 编辑提交参数
export function addshuxing(id, attr_id, data) {
    return request({
        url: `categories/${id}/attributes/${attr_id}`,
        method: "put",
        data
    })
}
// 添加参数
export function addcanshulist(id, data) {
    return request({
        url: `categories/${id}/attributes`,
        method: "post",
        data
    })
}
// 删除参数
export function shanchucanshulist(id, attr_id) {
    return request({
        url: `categories/${id}/attributes/${attr_id}`,
        method: "DELETE"
    })
}
// 数据报表
export function shujulist(){
    return request({
        url:"reports/type/1",
        method:"get"

    })
}
